import Vue from 'vue'
import Router from 'vue-router'
/*trafficsys的所有组件*/
//登录 注册 找回密码页面
import loginTrafficsys from '@/components/loginTrafficsys'
import loginTrafficsys2 from '@/components/loginTrafficsys2'
import registerTrafficsys from '@/components/registerTrafficsys'
import findPass from '@/components/findPass'

//系统主页面
import indexTrafficsys from '@/components/indexTrafficsys'

//驾驶员页面
import personalInfo from '@/components/driver/personalInfo'//个人主页
import driverTicket from '@/components/driver/driverTicket'//待处理违法记录
import driverExam from '@/components/driver/driverExam'//驾驶员考试

//车辆管理
import vehicle from '@/components/eleUi/vehicle'
//违章管理
import violation from '@/components/eleUi/violation'

//管理员页面
import managerDriveCardList from '@/components/manager/managerDriveCardList'//驾驶证管理
import managerDriverList from '@/components/manager/managerDriverList'//驾驶员管理
import managerExamManager from '@/components/manager/managerExamManager'//考试管理
import managerPoliceList from '@/components/manager/managerPoliceList'//警员管理
import managerTicket from '@/components/manager/managerTicket'//罚单管理
import managerTravelCardList from '@/components/manager/managerTravelCardList'//行驶证管理


//警员页面
import policeDriveCardList from '@/components/police/policeDriveCardList'//驾驶证管理
import policeDriverList from '@/components/police/policeDriverList'//驾驶员管理
import policeTicket from '@/components/police/policeTicket'//警员罚单管理
import policeTravelCardList from '@/components/police/policeTravelCardList'//行驶证管理

/* 引入aliPay.vue组件 */
import aliPay from '@/components/test/aliPay'
/* 引入error.vue组件 */
import error from '@/components/test/error'
/* 引入login.vue组件 */
import login from '@/components/test/login'
/* 引入userList.vue组件 */
import userList from '@/components/test/userList'
/* 引入loginElement.vue组件 */
import loginElement from '@/components/test/loginElement'
/* 引入indexElement.vue组件 */
import indexElement from '@/components/test/indexElement'
/* 引入userListElement.vue组件 */
import userListElement from '@/components/test/userListElement'

Vue.use(Router)

export default new Router({
  routes: [

    // trafficsys的全部页面
    // 驾驶员登录页面
     {
       path:"/loginTrafficsys",
       name:"loginTrafficsys",
       component:loginTrafficsys
     },
     // 驾驶员注册页面
     {
       path:"/registerTrafficsys",
       name:"registerTrafficsys",
       component:registerTrafficsys
     },
     // 警员登录页面
     {
       path:"/loginTrafficsys2",
       name:"loginTrafficsys2",
       component:loginTrafficsys2
     },
     // 驾驶员找回密码页面
     {
       path:"/findPass",
       name:"findPass",
       component:findPass
     },
     //主页面
     {
       path:"/indexTrafficsys",
       meta:{"isLogin":true},
       name:"indexTrafficsys",
       component:indexTrafficsys,
       children:[
         /*************管理员页面*******************/
         //管理员管理 警员列表页面
         {
           path: 'managerPoliceList',
           name: 'managerPoliceList',
           component:  managerPoliceList
         },
         // 管理员管理 驾驶员列表页面
         {
           path: 'managerDriverList',
           name: 'managerDriverList',
           component:  managerDriverList
         },
         // 管理员管理 驾驶证列表页面
         {
           path: 'managerDriveCardList',
           name: 'managerDriveCardList',
           component:  managerDriveCardList
         },
         // 管理员管理 行驶证列表页面
         {
           path: 'managerTravelCardList',
           name: 'managerTravelCardList',
           component:  managerTravelCardList
         },
         // 管理员管理考试列表页面
         {
           path: 'managerExamManager',
           name: 'managerExamManager',
           component:  managerExamManager
         },
         // 管理员罚单管理列表页面
         {
           path: 'managerTicket',
           name: 'managerTicket',
           component:  managerTicket
         },
         /***************警员管理*********************/
         // 警员管理 驾驶员列表页面
         {
           path: 'policeDriverList',
           name: 'policeDriverList',
           component:  policeDriverList
         },
         // 警员管理 驾驶证列表页面
         {
           path: 'policeDriveCardList',
           name: 'policeDriveCardList',
           component:  policeDriveCardList
         },
         // 警员管理 行驶证列表页面
         {
           path: 'policeTravelCardList',
           name: 'policeTravelCardList',
           component:  policeTravelCardList
         },
         //警员管理 罚单管理页面
         {
           path: 'policeTicket',
           name: 'policeTicket',
           component: policeTicket
         },
          /***************驾驶员管理*********************/
         // 驾驶员管理 驾驶员个人信息页面
         {
           path: 'personalInfo',
           name: 'personalInfo',
           component:  personalInfo
         },
         // 驾驶员管理 驾驶员处罚单列表处理页面
         {
           path: 'driverTicket',
           name: 'driverTicket',
           component:  driverTicket
         },
         // 驾驶员管理 驾驶证考试页面
         {
           path: 'driverExam',
           name: 'driverExam',
           component:  driverExam
         },
		 //违章管理
		  {
		  path: 'violation',
		  name: 'violation',
		  component:  violation
		 },
		 //车辆管理
		 {
		  path: 'vehicle',
		  name: 'vehicle',
		  component:  vehicle
		 }
       ]
     },

    // trafficsys的全部页面
    {
      // "/" 默认启动项目的访问地址
      path: '/login',//指的访问组件login.vue的地址
      name: 'login',//组件名称描述
      component:  login //对应的是引入组件的别名
    },
    {

      path: '/userList',
      name: 'userList',
      component:  userList
    },
    {

      path: '/loginElement',
      name: 'loginElement',
      component:  loginElement
    },
    {
      path: '/indexElement',
      meta:{"isLogin":true},
      name: 'indexElement',
      component:  indexElement,
      children:[
        {
          path: 'userListElement',
          name: 'userListElement',
          component:  userListElement
        },
        {
          path: 'aliPay',
          name: 'aliPay',
          component:  aliPay
        }
      ]
    },
    {
      // "*" 当没有对应页面时 跳转到error页面
      path: '*',
      name: 'error',
      component:  error
    }
  ]
})
const originalPush = Router.prototype.push

Router.prototype.push = function push(location, onResolve, onReject) {

if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)

return originalPush.call(this, location).catch(err => err)

}